package top.healthylife.gateway.platformchain.api.black.personal.query;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.basics.utils.exception.BusinessException;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.core.util.SystemConfigUtils;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.chain.dto.personal.query.req.ChainPersonalBlackListQueryReqDto;
import top.healthylife.gateway.platform.chain.dto.personal.query.res.ChainPersonalBlackListQueryResDto;
import top.healthylife.gateway.platformchain.api.config.SystemConfig;
import top.healthylife.gateway.platformchain.api.util.OutHttpUtil;

/**
 * @author : GaoZeXi
 * @date 2021/5/7 17:54
 */
@Slf4j
@Service
@ApiServiceExplain(price = 20, apiName = "个人黑名单-查询", info = "查询个人黑名单数据")
public class PersonalBlackListQueryApi implements ParentFace<ChainPersonalBlackListQueryReqDto, ChainPersonalBlackListQueryResDto> {
    private static final String URL = OutHttpUtil.BASE_URL+"/bcapi/api/blacklist/personal?personalCode=";
    @Override
    public ChainPersonalBlackListQueryResDto execute(ChainPersonalBlackListQueryReqDto reqDto) {
        String idNumber = reqDto.getIdNumber();
        if(ObjectUtil.isEmpty(idNumber)){
            throw new BusinessException("身份证号码不能为空");
        }
        return OutHttpUtil.get(URL+ idNumber, (SystemConfig) SystemConfigUtils.get()
                , ChainPersonalBlackListQueryResDto.class);
    }
}
